package com.freshminds.saudiproject;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.RatingBar;
import android.widget.TextView;

public class VideoAdapter extends BaseAdapter 
{
	Context context;
	ArrayList<Video>data;
	LayoutInflater layoutInflater;
	
	
public VideoAdapter(Context context,ArrayList<Video>data) 
{
	this.context=context;
	this.data=data;
	layoutInflater=(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	
}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return data.size();
	}

	@Override
	public Object getItem(int position)
	{
		// TODO Auto-generated method stub
		return data.get(position);
	}

	@Override
	public long getItemId(int id) {
		// TODO Auto-generated method stub
		return id;
	}

	@Override
	public View getView(int position, View view, ViewGroup arg2) 
	{
		
		if(view==null)
		{
			view =layoutInflater.inflate(R.layout.row_video, null);
		}
		TextView txtTitle=(TextView)view.findViewById(R.id.videotitle);
		RatingBar ratingBar=(RatingBar)view.findViewById(R.id.videorRating);
		
		
		txtTitle.setText(data.get(position).getTitle());
		ratingBar.setRating(data.get(position).getRating());
		return view;
	}
}